# the minimum version of CMake.
cmake_minimum_required(VERSION 3.4.1)
project(NapiDemo)


set(AV_CODEC_LIB_NAME avcodec)

include_directories(${CMAKE_CURRENT_SOURCE_DIR}
                    ${CMAKE_CURRENT_SOURCE_DIR}/include)

set(AVCODEC_FW_PATH_BASE ${CMAKE_CURRENT_SOURCE_DIR}/AvCodecFramework)
set(NAPI_PATH_BASE ${CMAKE_CURRENT_SOURCE_DIR}/napi)

file(GLOB_RECURSE AVCODEC_FRAMEWORK_SOURCES "${AVCODEC_FW_PATH_BASE}/*.[ch]pp" "${AVCODEC_FW_PATH_BASE}/*.c")
file(GLOB_RECURSE NAPI_SOURCES "${NAPI_PATH_BASE}/*.[ch]pp" "${NAPI_PATH_BASE}/*.c")
file(GLOB_RECURSE ROOT_SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/*.[ch]pp" "${CMAKE_CURRENT_SOURCE_DIR}/*.c")

add_library(${AV_CODEC_LIB_NAME} SHARED ${ROOT_SOURCES})

find_library( # Sets the name of the path variable.
              hilog-lib
              # Specifies the name of the NDK library that
              # you want CMake to locate.
              hilog_ndk.z )
find_library( # Sets the name of the path variable.
              libnapi-lib
              # Specifies the name of the NDK library that
              # you want CMake to locate.
              ace_napi.z )
find_library(mediacodec-lib
            libnative_media_venc.so)
find_library(meidacodeccore-lib
            libnative_media_core.so)
find_library(meidacodecbase-lib
            libnative_media_codecbase.so)
find_library(avcodec-lib
            libnative_av_codec_codec.so)
find_library(avcodeccore-lib
            libnative_av_codec_core.so)
find_library(uv-lib
            libuv.so)
target_link_libraries(${AV_CODEC_LIB_NAME} PUBLIC
             ${libnapi-lib}
             ${hilog-lib}
             ${mediacodec-lib}
             ${meidacodeccore-lib}
             ${meidacodecbase-lib}
             ${uv-lib})